/*
 * @(#)SmsBO.java $version 2011. 10. 14
 * 
 * Copyright 2011 NHN Corp. All rights Reserved.
 * NHN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

package com.hangame.mbl.bo;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.hangame.mbl.constant.CommonConst;

import com.nhn.laputa.sms.SmsInfo;
import com.nhn.laputa.sms.module.SMS;
import com.nhn.laputa.sms.module.SMSType;

// TODO: Auto-generated Javadoc
/**
 * The Class SmsBO.
 * 
 * @author khpark
 */
public class SmsBO {
	
	/** The log. */
	private static Log log = LogFactory.getLog(SmsBO.class);

	/**
	 * Send sms for group.
	 * 
	 * @param smsInfoList the sms info list
	 * @return true, if successful
	 */
	public boolean sendSMSForGroup(List<SmsInfo> smsInfoList) {
		try {
			if (smsInfoList != null && smsInfoList.size() > 0) {
				SmsInfo[] smsInfo = SMS.sendGroup(SMSType.HANGAME_COMMON_WEB, CommonConst.PROJECT_NAME, smsInfoList.toArray(new SmsInfo[0]));
				if (smsInfo == null) {
					throw new Exception();
				}
				log.debug("SMS 전송 성공");
			}
		} catch (Exception e) {
			log.error("SMS 전송 실패", e);
			return false;
		}

		return true;
	}

	/**
	 * Send sms for one.
	 * 
	 * @param sndNum the snd num
	 * @param rcvNum the rcv num
	 * @param content the content
	 * @return true, if successful
	 */
	public boolean sendSMSForOne(String sndNum, String rcvNum, String content) {
		try {
			String result = SMS.send(SMSType.HANGAME_COMMON_WEB, CommonConst.PROJECT_NAME, sndNum, rcvNum, content);

			if (result == null) {
				throw new Exception();
			} else {
				log.debug("SMS 전송완료 : sndNum = " + sndNum + ", sndNum = " + rcvNum);
			}
		} catch (Exception e) {
			log.error("SMS 전송실패 : sndNum = " + sndNum + ", sndNum = " + rcvNum, e);
			return false;
		}

		return true;
	}

}
